//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows;
using System.Windows.Media;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class SystemColor : ColorBase
    {
        private SystemColorValue _val;

        public SystemColorValue Value
        {
            get { return _val; }
            set { _val = value; }
        }


        protected override Color ResolveRawColor(ColorScheme colorScheme)
        {
            switch (Value)
            {
                case SystemColorValue.DarkShadow3D:
                    throw new NotImplementedException();
                case SystemColorValue.Light3D:
                    throw new NotImplementedException();
                case SystemColorValue.ActiveBorder:
                    return SystemColors.ActiveBorderColor;
                case SystemColorValue.ActiveCaption:
                    return SystemColors.ActiveCaptionColor;
                case SystemColorValue.AppWorkspace:
                    return SystemColors.AppWorkspaceColor;
                case SystemColorValue.Background:
                    throw new NotImplementedException();
                case SystemColorValue.ButtonFace:
                    throw new NotImplementedException();
                case SystemColorValue.ButtonHighlight:
                    throw new NotImplementedException();
                case SystemColorValue.ButtonShadow:
                    throw new NotImplementedException();
                case SystemColorValue.ButtonText:
                    return SystemColors.ControlTextColor;
                case SystemColorValue.CaptionText:
                    throw new NotImplementedException();
                case SystemColorValue.GradientActiveCaption:
                    throw new NotImplementedException();
                case SystemColorValue.GradientInactiveCaption:
                    throw new NotImplementedException();
                case SystemColorValue.GrayText:
                    throw new NotImplementedException();
                case SystemColorValue.Highlight:
                    return SystemColors.HighlightColor;
                case SystemColorValue.HighlightText:
                    return SystemColors.HighlightTextColor;
                case SystemColorValue.HotLight:
                    throw new NotImplementedException();
                case SystemColorValue.InactiveBorder:
                    return SystemColors.InactiveBorderColor;
                case SystemColorValue.InactiveCaption:
                    return SystemColors.InactiveCaptionColor;
                case SystemColorValue.InactiveCaptionText:
                    return SystemColors.InactiveCaptionTextColor;
                case SystemColorValue.InfoBk:
                    throw new NotImplementedException();
                case SystemColorValue.InfoText:
                    return SystemColors.InfoTextColor;
                case SystemColorValue.Menu:
                    return SystemColors.MenuColor;
                case SystemColorValue.MenuBar:
                    return SystemColors.MenuBarColor;
                case SystemColorValue.MenuHighlight:
                    return SystemColors.MenuHighlightColor;
                case SystemColorValue.MenuText:
                    return SystemColors.MenuTextColor;
                case SystemColorValue.ScrollBar:
                    return SystemColors.ScrollBarColor;
                case SystemColorValue.Window:
                    return SystemColors.WindowColor;
                case SystemColorValue.WindowFrame:
                    return SystemColors.WindowFrameColor;
                case SystemColorValue.WindowText:
                    return SystemColors.WindowTextColor;
                default:
                    throw new NotSupportedException();
            }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("sysClr"))
            {
                Value = c.GetEnum<SystemColorValue>("val");
                ReadTransforms(c);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("sysClr"))
            {
                c.SetEnum("val", Value);
                WriteTransforms(c);
            }
        }
    }
}